package org.fhkoeln.sgdm.sudoku;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;

import javax.swing.JOptionPane;

import org.fhkoeln.sgdm.sudoku.gui.MainFrame;
import org.fhkoeln.sgdm.sudoku.gui.TippFrame;

public class Starter
{
	static FileOutputStream fos = null;
	static Writer w = null;
	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		TippFrame.getInstance();
		TippFrame.getInstance().addText("LALELO");
		new MainFrame();
	}
	
	public static void error(String text)
	{
		debug(text);
		
		JOptionPane.showMessageDialog(null, text);
		
	}
	
	public static void debug(String text)
	{
		try
		{
			if(fos == null || w == null)
			{
				File tmp = new File("out.txt");
				if(tmp != null && tmp.exists())
				{
					tmp.delete();
				}
			  fos = new FileOutputStream("out.txt");
			  w = 
			    new BufferedWriter(new OutputStreamWriter(fos, "Cp850"));
			}
			
			  w.write(text + "\n");
			  System.out.println(text);
			  w.flush();
		} catch (FileNotFoundException e)
		{
			e.printStackTrace();
		} catch (UnsupportedEncodingException e)
		{
			e.printStackTrace();
		} catch (IOException e)
		{
			e.printStackTrace();
		}
	}

}
